<template>
	<view class="content">
		<view class="section-0">
			<view class="section-body">
				<view class="frequency">
					会议名称：
					<br />
					<span>{{ name || '-' }}</span>
				</view>
			</view>
		</view>
		<view class="section-1">
			<timeLine :list="list"></timeLine>
		</view>
		<view class="botton">
			<button v-show="show == 1"  class="shanchu" @click="shows = true">删除</button>
			<button v-show="show == 1" class="tijiao" @click="editMeeting()">编辑</button>
		</view>
		<view>
			<u-modal :show="shows" :title="title" :content="content" :showCancelButton="true" @confirm="confirm" @cancel="cancel"></u-modal>
		</view>
	</view>
</template>

<script>
import { editMeeting } from '@/api/meeting.js'
const meetingMap = {
	user_name: {
		type: 'text',
		name: '会议发起人',
		filter: val => {
			return val
		}
	},
	// meeting_type: {
	// 	type:'text',
	// 	name: '会议类型',
	// 	filter: (val) => {
	// 		let str = str;
	// 		switch (val) {
	// 			case "1":
	// 				str = '例会';
	// 				break;
	// 			case "2":
	// 				str = '站班会';
	// 				break;
	// 			case "3":
	// 				str = '安委会';
	// 				break;
	// 			case "5":
	// 				str = '启委会';
	// 				break;
	// 			case "6":
	// 				str = '工程月例会';
	// 				break;
	// 			case "7":
	// 				str = '第一次工地例会';
	// 				break;
	// 			default:
	// 				str = val;
	// 				break;
	// 		}
	// 		return str;
	// 	}
	// },
	meeting_time: {
		type: 'text',
		name: '会议时间',
		filter: val => val.substring(0, 10)
	},
	meeting_duration: {
		type: 'text',
		name: '会议时长',
		filter: val => {
			// val=1
			if (val == null) {
				return ''
			} else {
				return val + '分钟'
			}
		}
	},
	meet_file_content: {
		type: 'text',
		name: '会议内容',
		filter: val => {
			return val
		}
	},
	meeting_file_path: {
		type: 'image',
		name: '会议照片',
		filter: val => {
			return [
				{
					url: val
				}
			]
		}
	},
	meeting_av_path: {
		type: 'video',
		name: '会议视频',
		filter: val => {
			return [
				{
					url: val
				}
			]
		}
	},
	meeting_audio_path: {
		type: 'audio',
		name: '会议录音',
		filter: val => {
			return [
				{
					url: val
				}
			]
		}
	}
}
import { meettingDetailsApi, meettingDelApi } from '@/api/duty.js'
import { mapGetters, mapActions } from 'vuex'
import timeLine from '@/components/time_line/danduzujian.vue'
export default {
	components: {
		timeLine
	},
	data() {
		return {
			shows: false,
			title:'提示！',
			content: '是否确认删除？',
			name: '',
			list: [],
			show: '',
			id: '',
			project_id: '',
			meetingId: ''
		}
	},
	methods: {
		editMeeting() {
			uni.navigateTo({
				url: '/pages/work/manager/work_manage/meeting/editmeeting?meetingId=' + this.id + '&show=' + this.show + '&project_id=' + this.project_id
			})
		},
		// 删除
		confirm() {
			meettingDelApi({ id: this.id }).then(res => {
				uni.showLoading()
				if (res.data.code == 1) {
					uni.showToast({
						icon: 'none',
						title: '删除成功'
					})
					this.shows = false
					// setTimeout(() => {
					// 	uni.navigateBack()
					// }, 1000)
					uni.navigateBack({
						delta: 2
					})
					// uni.navigateTo({
					// 	url: '/pages/work/manager/work_manage/meeting/index?curIdx='+ 1 + '&show=' + this.show
					// })
				}
				uni.hideLoading()
			})
		},
		// 不删除
		cancel() {
			this.shows = false
		},
		go(item) {
			uni.navigateTo({
				url: item.path
			})
		},
		async fetchData() {
			uni.showLoading({
				title: '加载中...'
			})
			const { data } = await meettingDetailsApi({
				id: this.id
			})
			this.name = data.data.meeting_name
			this.project_id = data.data.project_id
			if (data.code === 1) {
				let arr = []
				let res = data.data
				for (let key in meetingMap) {
					let item = {}
					if (meetingMap[key]) {
						var type = meetingMap[key].type
						item = {
							title: meetingMap[key].name,
							content: {
								type: type,
								value: meetingMap[key].filter(res[key])
							}
						}
						if (res[key] != null && res[key] != '') {
							arr.push(item)
						}
					}
				}
				this.list =arr
				console.log(this.list);
			}
			uni.hideLoading()
		}
	},
	onLoad(data) {
		uni.hideLoading()
		this.show = data.show
		this.id = data.id
	},
	onShow() {
				uni.hideLoading()
		this.fetchData()
	}
	// onReady() {
	// 	this.fetchData();
	// },
}
</script>

<style lang="scss" scoped>
.content {
	background-color: #fff;
}

.section-0 {
	width: 100%;
	background-color: #3a5cf4;

	.section-body {
		width: 100%;
		padding-left: 40rpx;
		height: 180rpx;
		padding-right: 40rpx;
		padding-bottom: 50rpx;
		background-color: #1534ce;
		background-size: cover;
		background-repeat: no-repeat;
		border-top-left-radius: 50rpx;
		border-top-right-radius: 50rpx;
		overflow: hidden;
		box-sizing: border-box;

		.frequency {
			margin-top: 15rpx;
			width: 100%;
			height: 180rpx;
			line-height: 50rpx;
			font-size: 26rpx;
			color: #87c6ff;
			span {
				font-size: 20px;
				color: #fff;
			}
		}
	}
}
.section-2 {
	width: 90%;
	height: 300px;
	position: fixed;
	z-index: 11;
	margin-left: 5%;
	background-color: #fff;
	border: 1px solid #cecece;
	border-radius: 10px;
}
.section-1 {
	position: relative;
	top: -50rpx;
	z-index: 10;
	background-color: #fff;
	border-top-left-radius: 50rpx;
	border-top-right-radius: 50rpx;
	box-sizing: border-box;
	padding: 0 40rpx;
	padding-top: 60rpx;
	margin-bottom: 50rpx;
}
.botton {
	width: 100vw;
	display: flex;
	position: fixed;
	bottom: 0px;
	button {
		width: 50vw;
		background-color: #1534ce;
		color: #ffffff;
		font-size: 15px;
		text-align: center;
	}
	.shanchu {
		border-radius: 30rpx 0 0 30rpx;
	}
	.tijiao {
		border-radius: 0 30rpx 30rpx 0;
	}
}
</style>
